<template>
  <div class="news">
    <div class="centered">
        <div class="news-header">
            <span class="left"></span>
            <h3>新闻资讯</h3>
            <p>LATEST NEWS</p>
            <span class="right"></span>  
        </div>
        <div class="left">
            <router-link :to="{name:'NewsDetails',params:{id:this.firstlist.id}}">
                <img :src="this.firstlist.cover" alt="新闻图片">
            </router-link>
            <dl>
                <dt>
                    <router-link :to="{name:'NewsDetails',params:{id:this.firstlist.id}}" class="title">{{this.firstlist.title}}</router-link>
                </dt>
                <dd>{{this.firstlist.excerpt}}</dd>
            </dl>
        </div>
        <div class="right" >
            <dl class="news-1" v-for="(newslists,index) in newslist" :key="index"  @mouseover="wordsColor(index)" @mouseout="wordsColor_1(index)">
                <dt>
                    <router-link :to="{name:'NewsDetails',params:{id:newslists.id}}" class="titles">{{newslists.title}}</router-link>
                </dt>
                <dd>{{newslists.excerpt}}</dd>
                <div class="time first">
                    <span class="time-1">{{newslists.created_day.day}}</span>
                    <span class="time-2">{{newslists.created_day.month}}</span>    
                </div>
            </dl>
        </div>
        <router-link :to="{ path: '/Infomation'}" class="button">查看更多</router-link>
    </div>
  </div>
</template>
<script>
export default {
  name: 'News',
  data(){
      return{
        newslist: [],
        firstlist:{}
      }
  },
  created(){
      var node = this;
      window.$.get(this.apiUrl + '/articles/home', {category: 1, limit: 4}, function(res){
          node.newslist = res.data;
          node.firstlist = res.meta.first;
      })
  },
  methods: {
    wordsColor(index){
      let words = document.getElementsByClassName("titles")[index];
      words.style.color = '#009ae9';
    },
    wordsColor_1(index){
       let words = document.getElementsByClassName("titles")[index];
       words.style.color = '#000';
    }
  }
}
</script>
<style scoped>
.news{
    width: 100%;
    height: 630px;
    margin-top: 150px;
}
.news .centered{
    width: 1200px;
    height: 630px;
    margin: 0 auto;
    position: relative;
}
.news .centered .news-header{
    width: 1200px;
    height: 61px;
    text-align: center;
    position: relative; 
}
.news .centered .news-header h3{
  width: 218px;
  height: 45px;
  font-size: 36px;
  color: #110567;
  line-height: 30px;
  display: inline-block;
}
.news .centered .news-header p{
  width: 130px;
  height: 18px;
  font-size: 18px;
  line-height: 16px;
  color: #000;
  position: absolute;
  left: 541px;
  top: 46px;
}
.news .centered .news-header .left{
  width: 290px;
  height: 0;
  border-top: solid 3px #009ae9;
  position: absolute;
  left: 163px;
  top: 18px;
}
.news .centered .news-header .right{
  width: 290px;
  height: 0;
  border-top: 3px solid #009ae9;
  position: absolute;
  right: 157px;
  top: 18px;
}
.news .centered .left{
    width: 522px;
    height: 399px;
    padding-top: 57px;
    display: inline-block;
}
.news .centered .left img{
    width: 521px;
    height: 293px;
}
.news .centered .left dl{
    width: 522px;
    height: 88px;
    margin-top: 18px;   
}
.news .centered .left dt{
    width: 522px;
    height: 22px;
    font-size: 18px;
    color: #009ae9;
}
.news .centered .left dt a{
    width: 522px;
    height: 22px;
    font-size: 18px;
    color: #009ae9;
    text-decoration: none;
    display: inline-block;
}
.news .centered .left dd{
    width: 522px;
    height: 52px;
    font-size: 14px;
    color: #999;
    margin-top: 14px;
    line-height: 16px;
}
.news .centered .right{
    width: 556px;
    height: 400px;
    margin-left: 117px;
    display: inline-block;
    position: absolute;
    top: 95px; 
}
.news .centered .right dl{
    width: 556px;
    height: 150px;
    padding-left: 100px; 
}
.news .centered .right dl:nth-child(2){
    margin-top: 5px;
}
.news .centered .right dl:nth-child(3){
    margin-top: 1px;
}
.news .centered .right .news-1{
    margin-top: 25px;
}
.news .centered .right dl dt{
    width: 100%;
    height: 19px;
    font-size: 18px;
    color: #000;
    line-height: 19px;
    margin-left: 17px;
    overflow: hidden;
}
.news .centered .right dl dt a{
    width: 100%;
    height: 19px;
    font-size: 18px;
    color: #000;
    line-height: 19px;
    display: inline-block;
    text-decoration: none;
}
.news .centered .right dl dd{
    width: 100%;
    height: 85px;
    font-size: 14px;
    color: #999;
    line-height: 18px;
    margin-top: 12px;
    margin-left: 17px;
}
.news .centered .right .time{
    width: 96px;
    height: 96px;
    background-color: #d2d2d2;
    text-align: center;
    box-sizing: border-box;
    padding-top: 20px;
}
.news .centered .right .first .time-1{
    font-size: 24px;
    color: #666;
    display: block;
}
.news .centered .right .first .time-2{
    font-size: 18px;
    color: #666;
}
.news .centered .right dl:nth-child(1) .first{
    position: absolute;
    left: 0;
    top: 20px;
}
.news .centered .right dl:nth-child(2) .first{
    position: absolute;
    left: 0;
    top: 170px;
}
.news .centered .right dl:nth-child(3) .first{
    position: absolute;
    left: 0;
    top: 320px;
}
.news .centered .button{
  width: 170px;
  height: 50px;
  background-color: #009ae9;;
  border: 0;
  border-radius: 20px;
  outline: none;
  position: absolute;
  top: 580px;
  left: 515px;
  text-align: center;
  font-size: 18px;
  line-height: 50px;
  color: #fff;
  text-decoration: none;
}
</style>
